/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2019-2022. All rights reserved.
 * Description:hcom executor obtain the header file.
 * Author:wangwenwen
 * Create:2019-12-10
 */

#ifndef EXECUTOR_MESSAGE_H
#define EXECUTOR_MESSAGE_H

#include <mutex>
#include <map>
#include <queue>
#include <string>
#include <functional>
#include <hccl/hccl_types.h>

#include "base.h"

namespace hccl {
using HcomOperation_t = struct HcomOperation;
using HcomRemoteOperation_t = struct HcomRemoteOperation;
using StatusCallback = std::function<void(HcclResult status)>;

struct RemoteAccessInfo {
    std::string remoteAccessType;
};

enum class ExecutorMessageType {
    MSG_OPBASED = 0,
    MSG_REMOTE_ACCESS = 1,
    MSG_ALLTOALL = 2,
    MSG_ALLTOALLVC = 3,
    MSG_REMOTE_OP = 4
};

class ExecutorMessage {
public:
    ExecutorMessage();
    ~ExecutorMessage();

    ExecutorMessageType GetMessageType();

    void SetOperationMessage(const HcomOperation_t& opInfo);
    HcomOperation_t GetOperationMessage() const;

    void SetRemoteOperationMessage(const HcomRemoteOperationParams& opInfo);
    HcomRemoteOperationParams GetRemoteOperationMessage() const;

    void SetRemoteAccessMessage(const std::string& remoteAccessType);
    const RemoteAccessInfo& GetRemoteAccessMessage() const;

    void SetAlltoAllMessage(const HcomAllToAllVParams& opInfo, bool isGatherAlltoAll = false);
    HcomAllToAllVParams GetAlltoAllMessage() const;

    void SetAlltoAllVCMessage(const HcomAllToAllVCParams& opInfo);
    HcomAllToAllVCParams GetAlltoAllVCMessage() const;

    void SetStatusCallback(StatusCallback callBack);
    StatusCallback GetStatusCallback() const;

    bool isGatherAlltoAll_;
private:
    HcomOperation_t hcomOperationInfo_;
    HcomRemoteOperationParams hcomRemoteOperationInfo_;
    RemoteAccessInfo remoteAccessInfo_;
    HcomAllToAllVParams hcomAlltoAllInfo_;
    HcomAllToAllVCParams hcomAlltoAllVCInfo_;
    StatusCallback statusCallback_;
    ExecutorMessageType messageType_;
};
}

#endif